home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / IM_3 .adf / Exec / piarc.LZH / vistabin.rexx < prev    next >
OS/2 REXX Batch file  |  1992-04-13  |  6KB  |  264 lines

  1. /*
  2.  * VISTABIN.rexx  - VISTAPRO (2.0) binary altitude file creation from
  3.  *                  the image processor's main buffer
  4.  *
  5.  *  Written by: Barry Chalmers
  6.  * Last Update: February 16th, 1992
  7.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  8.  * ---------------------------------------------------------------------------
  9.  *    Revision: 1.00
  10.  */
  11.  
  12. /*
  13.  * open rexxsupport.library -- needed for some functions
  14.  */
  15. if ~show('L',"rexxsupport.library") then do
  16.   if addlib('rexxsupport.library',0,-30,0) then do
  17.       /* everything's ok */
  18.     end;
  19.   else do
  20.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  21.     say 'Cannot operate script without this library - sorry!';
  22.     exit 10;
  23.     end;
  24.   end;
  25.  
  26. prtnme = 'IP_Port';
  27. if show('P','IP_Port') = 0 then do
  28.   if show('P','IM_Port') = 0 then do
  29.     say "Can't find image processor's ARexx port!!!";
  30.     say "This script requires IP, IM or IM F/c to run!";
  31.     exit(20);
  32.     end;
  33.   else do
  34.     prtnme = 'IM_Port';
  35.     end;
  36.   end;
  37.  
  38. cmdpath = 'c:';
  39. if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  40.   do
  41.     cmdpath = readln(fhandle);
  42.     call close(fhandle);
  43.   end
  44.  
  45. /*
  46.  * Get the file name parts
  47.  */
  48.   prevpath = 'ram:';
  49.   if show('C',rawpath) = 1 then do
  50.     prevpath = getclip(rawpath);
  51.     end;
  52.   prevname = 'image';
  53.   if show('C',rawname) = 1 then do
  54.     prevname = getclip(rawname);
  55.     end;
  56.   prevext = '.vbn';
  57.   if show('C',rawext) = 1 then do
  58.     prevext = getclip(rawext);
  59.     end;
  60.   rawheight = 2000;
  61.   if show('C',rawalt) = 1 then do
  62.     rawheight = getclip(rawalt);
  63.     end;
  64.  
  65. address(prtnme);
  66.  
  67. options results;
  68. 'current';
  69. iinfo = result;
  70. options;
  71. parse var iinfo iname ',' inum ',' xw ',' yw ',' s
  72.  
  73.  
  74. if xw = 0 then do
  75.   'message "Main image is empty"';
  76.   exit 0;
  77.   end
  78. if yw = 0 then do
  79.   'message "Main image is empty"';
  80.   exit 0;
  81.   end
  82.  
  83. options results;
  84. 'gadgets "Save Vista Binary","Small (258x258)","Large","(514x514)","Huge","(1026x1026)"';
  85. pick = result;
  86. options;
  87.  
  88. if pick=0 then do
  89.   exit 0;
  90.   end;
  91. if pick=1 then do
  92.   xnew = 258;
  93.   ynew = 258;
  94.   end;
  95. if pick=2 then do
  96.   xnew = 514;
  97.   ynew = 514;
  98.   end;
  99. if pick=3 then do
  100.   xnew = 1026;
  101.   ynew = 1026;
  102.   end;
  103.  
  104. if xw ~= xnew | yw ~= ynew then do    /* Every language is different */
  105.   if xw > xnew | yw > ynew then do
  106.     stype = 1;
  107.     end;
  108.   if xw <= xnew & yw <= ynew then do
  109.     options results;
  110.     'gadgets "Stretch","to Size","Pad","to Size"';
  111.     stype = result;
  112.     options;
  113.     if stype=0 then do
  114.       exit 0;
  115.       end;
  116.     end;
  117.   
  118.     options results;
  119.     'askprop "Top Altitude:",'||rawheight||',100,10000';
  120.     rawheight = result;
  121.     options;
  122.     call setclip(rawalt,rawheight);
  123.   
  124.   
  125.   if stype = 1 then do
  126.     'entire';
  127.     options results;
  128.     'stretch '||xnew||' '||ynew||' visbin';
  129.     nbuff = result;
  130.     options;
  131.     'newcurrent '||nbuff;
  132.     end;
  133.   if stype = 2 then do
  134.     options results;
  135.     'newasprimary '||xnew||' '||ynew;
  136.     nbuff = result;
  137.     options;
  138.     'newsecondary '||inum;
  139.     'rect 0 0 '||xw||' '||yw;
  140.     'merge'
  141.     end;
  142.   end
  143.  
  144.   address(prtnme);
  145.   options results;
  146.   'filerequest "'||prevpath||'","'||prevname||'","'||prevext||'","Sv VisBin"';
  147.   binfile = result;
  148.   options;
  149.  
  150.   call checkfile(binfile);
  151.   
  152.   
  153.  
  154.   address(prtnme);
  155.   options results;
  156.   'jackin';
  157.   jackadr = result;
  158.   options;
  159.  
  160.   address command cmdpath||'vistabin '||jackadr||' 2 'rawheight||' '||binfile;
  161.  
  162.   address(prtnme);
  163.   'newcurrent '||inum;
  164.   'killbuff '||nbuff;
  165.   exit 0;
  166. end
  167.  
  168.  
  169. checkfile: 
  170. arg thefile;
  171.   if thefile = 'FR_CANCELLED' then do
  172.     address(prtnme);
  173.     'tofront';
  174.     exit 0;
  175.     end;
  176.   prevpath = gimmepath(thefile);
  177.   call setclip(rawpath,prevpath);
  178.   prevname = gimmename(thefile);
  179.   call setclip(rawname,prevname);
  180.   prevext  = gimmeext(thefile);
  181.   call setclip(rawext,prevext);
  182.   return;
  183.   end
  184.  
  185. /*
  186.  * gimmepath
  187.  *
  188.  * This takes the provided argument and sucks the path out of it, then
  189.  * returns that path to the caller, sans file name.
  190.  */
  191. gimmepath:
  192.   arg fullnamegx;
  193.     tempgx = reverse(fullnamegx);
  194.     lengx = length(fullnamegx);   /* get length of string */
  195.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  196.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  197.     seploc = 0; /* assumes current dir, no path supplied */
  198.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  199.       seploc = (lengx - slashdex)+1;
  200.       end;
  201.     else do
  202.       if colondex ~= 0 then do /* we assume we are on a device */
  203.         seploc = (lengx - colondex)+1;
  204.         end;
  205.       end;
  206.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  207.   gxpath = left(fullnamegx,seploc);
  208.   return(gxpath);
  209.   end
  210.  
  211.  
  212. gimmename:
  213.   arg fullnamegx;
  214.     tempgx = reverse(fullnamegx);
  215.     lengx = length(fullnamegx);   /* get length of string */
  216.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  217.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  218.     seploc = 0; /* assumes current dir, no path supplied */
  219.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  220.       seploc = (lengx - slashdex)+1;
  221.       end;
  222.     else do
  223.       if colondex ~= 0 then do /* we assume we are on a device */
  224.         seploc = (lengx - colondex)+1;
  225.         end;
  226.       end;
  227.   extpos = lastpos(".",fullnamegx) - 2;
  228.   if extpos > seploc then do
  229.     gxname = substr(fullnamegx,seploc+1,extpos-seploc+1);
  230.     end;
  231.   else do
  232.     gxname = substr(fullnamegx,seploc+1);
  233.     end;
  234.   return(gxname);
  235.   end
  236.  
  237.  
  238. gimmeext:
  239.   arg fullnamegx;
  240.     tempgx = reverse(fullnamegx);
  241.     lengx = length(fullnamegx);   /* get length of string */
  242.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  243.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  244.     seploc = 0; /* assumes current dir, no path supplied */
  245.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  246.       seploc = (lengx - slashdex)+1;
  247.       end;
  248.     else do
  249.       if colondex ~= 0 then do /* we assume we are on a device */
  250.         seploc = (lengx - colondex)+1;
  251.         end;
  252.       end;
  253.   extpos = lastpos(fullnamegx,'.');
  254.   if extpos > seploc then do
  255.     gxext = substr(fullnamegx,extpos+1);
  256.     end
  257.   else do
  258.     gxext = '';
  259.     end
  260.   return(gxext);
  261.   end
  262.  
  263.  
  264.